package com.gitee.zhanyao.single.util;

import java.util.Map;

public class TemplateUtil {

    private TemplateUtil() {
    }

    /**
     * 替换模版中的占位符（格式：{{xxxx}}）内容
     *
     * @param template 模版
     * @param params 填充参数
     * @return
     */
    public static String replaceTemplate(String template, Map<String, String> params) {
        String content = template;
        for (Map.Entry<String, String> entry: params.entrySet()) {
            content = content.replaceAll("\\{\\{" + entry.getKey() + "\\}\\}", entry.getValue());
        }
        return content;
    }

}
